package com.whatever;

import com.whatever.R;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class titleActivity extends Activity implements OnClickListener {
	
	private Context cxt = this;
	private static String playerName;
	private EditText textBox;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.title);
		
		TextView screenTitle = (TextView)findViewById(R.id.titleTextView0);
		TextView gameInstructions = (TextView)findViewById(R.id.titleTextView1);
		TextView startPrompt = (TextView)findViewById(R.id.titleTextView2);
		textBox = (EditText)findViewById(R.id.titleEditText0);
		Button start = (Button)findViewById(R.id.titleButton0);
		
		start.setText("Start!");
		screenTitle.setText("Whack-A-Dot!");
		gameInstructions.setText("Welcome to Whack-A-Dot! In this game, small, colored dots randomly appear and start bouncing around.  " +
				"Your job is to tap and destroy as many as you can before they can overwhelm you.  " + 
				"As the game progresses, the dots get smaller, faster, and more numerous.  ");
		startPrompt.setText("To get started, type your name in the bottom and click \"Start!\"");
		
		start.setOnClickListener(this);
	}

	public void onClick(View v) {
		do {
			textBox.setText("");
			textBox.setHint("Enter game duration:");
			playerName = textBox.getText().toString();
			System.out.println(playerName);
		} while(playerName == null);

		if(playerName != null) {
			Intent game = new Intent(cxt, NewGameActivity.class);
			cxt.startActivity(game);
		}
	}

	public static String getPlayerName() {
		return playerName;
	}
}
